﻿using DBModel.Entity;
using ILogicLayer.DTO;
using ILogicLayer.Interface;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace WebApiCoreFx.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    //[AllowAnonymous]
    public class ValuesController : ControllerBase
    {
        private readonly ILogger<ValuesController> logger;

        public ValuesController(ILogger<ValuesController> logger)
        {
            this.logger = logger;
        }

        // GET api/values
        [HttpGet]
        //[AllowAnonymous]
        //[MultipleCache]
        public string[] Get()
        {
            return new string[] { $"{Request.Scheme}://{Request.Host}{Request.Path}", $"(MiddlewareTest输入处理:{Request.Headers["TestMiddleware"]})" };
        }

        /// <summary>
        /// ValidateAntiForgeryToken特性(Request.Header包含X-XSRF-TOKEN才能正常请求)
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        [HttpPost]
        [AopDLL.Filter.CustomizeFilter]
        [ValidateAntiForgeryToken]
        public string Post([FromQuery] string value)
        {
            return $"___{value}";
        }

    }
}